/******************************************************************************
 Module Description: SABON  - Simple Access Business Object Network Ver 1.23
 Author: German M. Fuentes
 Email: gm_fuentes@yahoo.com, gm.fuentes@gmail.com
 ******************************************************************************
 Revision Log: 
 Please log any revision to this module for reference.
 Modified by  | Modified date  | Version | Reason
 GFuentes     | 09/12/2007     |   1.00	 | Create SABON Class. 
 GFuentes 	  | 04/14/2008 	   |   1.01	 | create getMsgResponse
 GFuentes     | 04/15/2008 	   |   1.02	 | create getHttpResponse(URLval,callBack) to get Reponse value
 GFuentes	  | 04/22/2008 	   |   1.03  | create overloads function pls see parseVal(strSource,strKey,format){...}
 GFuentes	  | 04/22/2008 	   |   1.03  | remove getHttpResponse(URLval), StateChange and DisplayResponse{...}
 GFuentes	  | 04/22/2008 	   |   1.03  | create formatSkin function to Format a skin of an html element which has innerHTML property.
 GFuentes	  | 04/22/2008 	   |   1.03  | create getChildById function(objID,childID){..) to find a child in an element.
 GFuentes	  | 04/22/2008 	   |   1.03  | create parseValByTagName function To parse a value by TagName of an HTML string.
 GFuentes	  | 04/23/2008 	   |   1.04  | create SABON class and DivPopUp
 CAmores	  | 04/23/2008 	   |   1.04  | create IsEmpty
 GFuentes	  | 04/23/2008 	   |   1.04  | add    addMethod function for over loading...
 GFuentes	  | 04/24/2008 	   |   1.05  | create tempElement function  - to create temporary html element.
 GFuentes	  | 04/24/2008 	   |   1.05  | create clearControls - to clear all the values of the controls.
 GFuentes	  | 04/25/2008 	   |   1.06  | create getCenterByHeightWidth function  - get center location for element 
 GFuentes	  | 04/25/2008 	   |   1.06  | create MessageBox method- to display custom box.
 GFuentes	  | 04/27/2008 	   |   1.07  | create makeObjectOnTop function - to make object on top place.
 GFuentes	  | 04/28/2008 	   |   1.08  | create GetWindowHeightWidth function - to get the height and width of window browser
 Camores	  | 05/01/2008 	   |   1.09  | create IsNumeric function for checks for numeric values.
 GFuentes	  | 05/06/2008 	   |   1.10  | create debug function dialog to easily debug errors
 GFuentes 	  | 05/07/2008 	   |   1.11  | add    inherits method to inherit from super class 
 GFuentes 	  | 05/07/2008 	   |   1.11  | create getChildsById function to get elements by Id on a parent object
 GFuentes 	  | 05/08/2008 	   |   1.12  | add    detectBrowser class and revise the code in order to integrate it into SABON class.
 GFuentes 	  | 05/08/2008 	   |   1.12  | add    isValidDate to validate a date.
 GFuentes 	  | 05/08/2008 	   |   1.12  | add    formatdate to format a date.
 GFuentes 	  | 05/08/2008 	   |   1.12  | create refreshContent function to refresh content of a page.
 GFuentes 	  | 05/09/2008 	   |   1.13  | create getCheckObjectsToArray function to get checked items in a table elements.
 GFuentes 	  | 05/09/2008 	   |   1.13  | create arrToDelimitedString function to convert array to a delimeted string.
 GFuentes 	  | 05/09/2008 	   |   1.13  | create getChilds function to get elements in a parent object
 GFuentes 	  | 05/12/2008 	   |   1.14  | create SetObjectValue function  to set value of an object element.  
 GFuentes 	  | 05/12/2008 	   |   1.14  | create TableHTML class, including addrow,deleterow and update row method.
 GFuentes 	  | 05/12/2008 	   |   1.14  | create Collection function is used for Objects Collection 
 GFuentes 	  | 05/12/2008 	   |   1.14  | create GetObjectValue function is used to get value of an object element. 
 GFuentes 	  | 05/12/2008 	   |   1.15  | create getElementByAttrName function is used to get elements by attribute name. 
 GFuentes 	  | 05/12/2008 	   |   1.15  | create FindObjectsByAttr function is used to find elements by attribute name and value. 
 GFuentes 	  | 05/19/2008 	   |   1.16  | create CreateDocClass function  to create document class which consist of elements based on the parent object/id.
 GFuentes 	  | 05/19/2008 	   |   1.17  | create single selection under formatGrid.
 GFuentes 	  | 06/06/2008 	   |   1.18  | create GetURLParamsVal get parameter value from URL(s) history. Create  logURL to log url history.
 GFuentes 	  | 07/02/2008 	   |   1.19  | create FileString to get a string value from a file name by extension, filename only, path/directory and format directory.
 GFuentes 	  | 07/02/2008 	   |   1.19  | create reverse prototype function for string.
 GFuentes 	  | 07/02/2008 	   |   1.19  | create IsAllowedFile To check the file by extension name to be allowed.
 GFuentes 	  | 07/04/2008 	   |   1.20  | create SearchStr To search for a string.
 GFuentes 	  | 07/10/2008 	   |   1.21  | create ListBox Class amd find method - use to find value of dropdown box elements and return the index of an item found.
 GFuentes 	  | 07/16/2008 	   |   1.22  | create searchAll function on HTMLTable Class - to search values in all columns
 GFuentes 	  | 07/16/2008 	   |   1.22  | create searchByColumnIndex function on HTMLTable Class - to search values in an index column
 GFuentes 	  | 07/16/2008 	   |   1.22  | create filter function on HTMLTable Class - to filter records by columns and value
 GFuentes 	  | 11/13/2008 	   |   1.23  | create checkAllBoxes function - to (check/uncheck) all boxes once the header box is checked/unchecked.
 




*******************************************************************************
 Note: If you wanted to add a modification, pls. indicate [create] - if it is your source code, 
 [add] if it is from other source and specify the url, and [remove] pls. make a backup copy under backup folder.    
*/
var p_QueryString="";
var _str="";

//new instance class of SABON
var sabon = new SABON;
//PETC Class Library
function SABON(){
	this.addMethod				= addMethod;
	this.arrToDelimitedString 	= ArrToDelimitedString;
	this.checkAllBoxes			= CheckAllBoxes;
	this.cBit					= CBit;
	this.checkInputs			= check_Inputs;
	this.checkOneByObject		= CheckOneByObject;
	this.clearControls			= clearControls;
	this.collection				= Collection;
	this.createCookie			= createCookie;
	this.createDocClass			= CreateDocClass;
	this.debug 					= debug;
	this.detectBrowser			= new DetectBrowser;
	this.divPopUp				= new DivPopUp;
	this.emailCheck				= emailCheck;
	this.fileString				= new FileString;
	this.findObjectsByAttr		= FindObjectsByAttr;	
	this.formatDate				= FormatDate;
	this.formatGrid				= gridStripe;
	this.formatSkin				= formatSkin;
	this.getCenterByHeightWidth	= GetCenterByHeightWidth;
	this.getCheckObjectsToArray = GetCheckObjectsToArray;
	this.getChildById			= getChildById;
	this.getChilds				= getChilds;
	this.getChildsById			= getChildsById;
	this.getE					= getE;
	this.getEByAttrName			= GetEByAttributeName;
	this.getEName				= getEName;
	this.getHttpResponse 		= getHttpResponse;
	this.getQuery				= GetQuery;
	this.getObjectValue			= GetObjectValue;
	this.getWindowHeightWidth 	= GetWindowHeightWidth;
	this.getURLParamsVal		= GetURLParamsVal;
	this.inherits 				= inherits;
	this.isAllowedFile			= IsAllowedFile;
	this.isDefinedObj			= isDefinedObj;
	this.isEmpty				= isEmpty;
	this.IsNumeric 				= IsNumeric;
	this.isValidDate			= IsValidDate;
	this.listBox				= new ListBox;
	this.listURL				= new Array;
	this.makeObjectOnTop		= MakeObjectOnTop;
	this.msgbox					= new MessageBox;
	this.parseVal				= parseVal;
	this.parseValByTagName 		= parseValByTagName;
	this.readCookie				= readCookie;
	this.refresh				= refresh;
	this.refreshContent 		= RefreshContent;
	this.removeIteminList		= removeIteminList;
	this.requestStatusBox		= RequestStatusBox;
	this.resetControls 			= resetControls;
	this.searchStr				= new SearchStr;
	this.setObjectValue			= SetObjectValue;	
	this.tableHTML				= new TableHTML;
	this.tempElement			= new TempElement;
	this.xmlHttpObject 			= new XMLHttpObject;


	//----| P R O T O T Y P E S |---------------------------------------------------------------------------------------------------------------------//
	//Eliminate trailing blanks
	String.prototype.strTrim = function() {
		return this.replace(/^\s+|\s+$/, ''); 
	}; //strTrim function
	
	//Reverse a String
	String.prototype.reverse = function(){
		splitext = this.split("");
		revertext = splitext.reverse();
		reversed = revertext.join("");
		return reversed;
	}
	//-------------------- METHODS ------------------------------------------------//

	//----| XMLHttpObject|---------------------------------------------------------------------------------------------------------------------//
	//function for initializing xmlhttprequest object.
	function XMLHttpObject(){
	var xmlhttp;
	
			try {xmlhttp = new XMLHttpRequest();}
			catch(e) {
					if(typeof ActiveXObject != 'undefined') {
					//Use IE's ActiveX items to load the file.
						try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} 
						catch(e) {
							try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
							catch(E) {xmlhttp = false;}
						}
					} else  {
						xmlhttp = false; //Browser don't support Ajax
					}
			
			}
	return 	xmlhttp;
	}
	
	//----| getHttpResponse|---------------------------------------------------------------------------------------------------------------------//
	//Function to return a call back function 
	//example:
	//1.)  sabon.getHttpResponse('controls/update.asp?pid=2'); //no call back method
	//2.)  sabon.getHttpResponse('controls/update.asp?pid=2',callBack); with call back method.
	//		function callBack(res){
	//			alert("this is a response from other page"	
	//		}
	function getHttpResponse(URLval){
	var callBack = 	arguments[1];
	var arglen=arguments.length;
	var args=arguments;
	logURL(URLval); // log url request
	var pos = URLval.indexOf("?") 
		if (pos==-1){
			URLval =  URLval + "?refresh=" + new Date().getTime().toString();
		}
		else{
			URLval =  URLval + "&refresh=" + new Date().getTime().toString();
		}
			var req =  new XMLHttpObject; 
			sabon.xmlHttpObject=req; // update xmlHttpObject to get status request
			req.onreadystatechange = function(){
				if(req.readyState == 4){	
					if(req.status == 200){
						if(typeof(callBack)=="function"){  
							callBack(InitAlias(req));
						}
					}	
					else{
						if(req.status>0){
							alert("Request has an error. \nRequest Status:" + req.status );
						}
						else{ //0 - is aborted request value
							callBack=null;
							arguments[1]=null
						}
					}	
				} 
			} 
			req.open("GET", URLval, true); 
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
			//req.setRequestHeader("Content-Type", "text/xml"); 
			req.send(null); 
	
	
		//private function to return object with two(2) properties
		//return short property words [req.text], unlike using req.responseText
		function InitAlias(req){
			this.xml =req.responseXML
			this.text = req.responseText
	
			var obj = new Array();
			for (i=0;i<args.length;i++){
				obj[i]=	args[i];	
			}
			
			this.args = obj;
	
			return this
		}		
	} 
	//----| addMethod |---------------------------------------------------------------------------------------------------------------------//
	//function for over loading
	function addMethod(object, name, fn){
		var old = object[ name ];
		object[ name ] = function(){
			if ( fn.length == arguments.length )
				return fn.apply( this, arguments );
			else if ( typeof old == 'function' )
				return old.apply( this, arguments );
		};
	}
	//----| parseVal - 1|---------------------------------------------------------------------------------------------------------------------//
	//to get a value of a delimited and formatted string
	//ex: parseVal("width:=30;height:=50;","width");
	//result = 30
	function parseVal(strSource,strKey){
		var pos=strSource.indexOf(strKey + ":=");
		if (pos<0) return "";
		var strArr1 		= strSource.substr(pos).split("::")
		var strArr2 		= strArr1[0].split(":="); 
		return strArr2[1].strTrim();
	}
	
	
	//----| parseVal - 2 |---------------------------------------------------------------------------------------------------------------------//
	//to get a value of a delimited and formatted string
	//ex: parseVal("width:30;height:50;","height",":and;");
	//result = 50
	//note: use (and) as a separator for equivalent(:) value and the group value(;) 
	
	addMethod(this, "parseVal", function(strSource,strKey,format){
		var arr = arguments[2].split("and");
		
		if(arr[0]=="" || arr[1]=="" || arr.length!=2){
			return "Invalid format";
		}
		var pos=strSource.indexOf(strKey + arr[0]);
		if (pos<0) return "";
		var strArr1 		= strSource.substr(pos).split(arr[1])
		var strArr2 		= strArr1[0].split(arr[0]); 
		return strArr2[1].strTrim();
	  });
	
	//----| parseValByTagName |---------------------------------------------------------------------------------------------------------------------//
	//To parse a value by TagName of an HTML string.
	function parseValByTagName(_html,_tagName){
	var pos;
		 var firstTag  = "<" + _tagName.toLowerCase() + ">";
		 var endTag  = "</" + _tagName.toLowerCase() + ">";
		 
		 pos  = _html.toLowerCase().indexOf(firstTag);
		 _html = _html.substr(pos + firstTag.length);
		 
		 pos  =  _html.toLowerCase().indexOf(endTag);
		_html= 	_html.substr(0,pos);
		
		_html = _html.replace(/\</, "")
		_html = _html.replace(/\>/, "")
		_html = _html.replace(/\//, "")
		return _html;	
	}
	//----| includeJS |---------------------------------------------------------------------------------------------------------------------//
	function includeJS(jsfile){
	
		var jsinclude = getE("jsinclude");
		if (jsinclude){	
			jsinclude.src= jsfile;
		}
		//return true
	}
	//----| CBit |---------------------------------------------------------------------------------------------------------------------//
	function CBit(pval){
		if (pval.toLowerCase()=="true"){
			return 1;
		}
		else{ return 0;}
	}
	
	//----| getE |---------------------------------------------------------------------------------------------------------------------//
	//Get Element on ID
	//  var x = getE(pStudent,div) 
	function getE()
	{
		var pElement = arguments[0]; 
		var pRoot = (arguments[1]) ? arguments[1] : "undefined" ;
		if (pRoot=="undefined"){
			return document.getElementById(pElement);
		}
		else{
			return pRoot.document.getElementById(pElement);	
		}
	}
	//----| getEName |---------------------------------------------------------------------------------------------------------------------//
	function getEName(name) {
		 var elem = document.getElementsByTagName('*');
		 var arr = new Array();
		 for(i = 0,iarr = 0; i < elem.length; i++) {
			  att = elem[i].getAttribute("id");
			  if(att == name) {
				   arr[iarr] = elem[i];
				   iarr++;
			  }
		 }
		 return arr;
	}
	//----| isDefinedObj |---------------------------------------------------------------------------------------------------------------------//
	function isDefinedObj(pVal){
		if(typeof(pVal)!="undefined"){return true;}else{return false;}
	}
	//----| emailCheck |---------------------------------------------------------------------------------------------------------------------//
	function emailCheck (emailStr) {
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			sabon.msgbox.show("Email address is invalid","Validate!");
			//alert("Email address is invalid.")
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		if (user.match(userPat)==null) {
			sabon.msgbox.show("The username doesn't seem to be valid.","Validate!");
			//alert("The username doesn't seem to be valid.")
			_focus(arguments[1]);
			return false
		}
		
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					sabon.msgbox.show("Destination IP address is invalid!","Validate!");
					//alert("Destination IP address is invalid!")
					_focus(arguments[1]);
				return false
				}
			}
			return true
		}
		
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			//alert("The domain name doesn't seem to be valid.")
			sabon.msgbox.show("The domain name doesn't seem to be valid.","Validate!");
			
			_focus(arguments[1]);
			return false
		}
		
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   //alert("The address must end in a three-letter domain, or two letter country.")
		   sabon.msgbox.show("The address must end in a three-letter domain, or two letter country.","Validate!");
		   
		   _focus(arguments[1]);
		   return false
		}
		
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   //alert(errStr)
		    sabon.msgbox.show(errStr,"Validate!");
		   _focus(arguments[1]);
		   return false
		}
		
		return true;
		
		function _focus(arg){
			 if (arg!=undefined){arg.focus();}
		}
	}
	//----| check_Inputs |---------------------------------------------------------------------------------------------------------------------//
	function check_Inputs(){ //version 1.0 GMFuentes Modules
	/*
	[1st parameter]
		-optional-array = check only the index/member of an array object (that having with the same id/name) 
		-blank			= check for blank
		-email			= verifiy for email
	[2nd paramters]
		- any input objects
		- - - - - - - - - - - - - - - - - - - - Examples - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
				 : sabon.checkInputs("blank",input1,input2,input3,input4,input5 <,...you can add more objects here.>)
				 : sabon.checkInputs("numeric,optional-array",input1[1],input2)
				 : sabon.checkInputs("email,",input1[1],input2[3])	 
				 : sabon.checkInputs("optional-array,blank,numeric",form1.plname,form1.pfname)
	*/
	var strArgs = arguments[0]
	var checker = arguments[0].split(",")
		for (var x=0;x<checker.length;x++){
			//checkValue(checker[x],arguments);
			if(checkValue(checker[x],arguments)){return false;};
		}
		function checkValue(pCheker,arg){
			for (var x=1;x<arg.length;x++){ //for input that has different
				if(arg[x]){
					if (strArgs.indexOf("optional-array")<0 ){ //if not optional array
						var objArr = sabon.getChildsById(document,arg[x].id); 
						for (var y=0;y<objArr.length;y++){
	
							switch(pCheker){
								case "blank":
									if (parseElementVal(objArr[y])==""){msg(1,objArr[y]);return true;};
									break;
								case "numeric":if(isNaN(parseElementVal(objArr[y])) || parseElementVal(objArr[y])==""){msg(2,objArr[y]);return true;};break;
								case "email":if(emailCheck(parseElementVal(objArr[y]),objArr[y])==false){return true;}break;
								default:break;
							}
						}
					}
					else{ //if optional array
						switch(pCheker){
							case "blank":if (parseElementVal(arg[x])==""){msg(1,arg[x]);return true;};break;
							case "numeric":if(isNaN(parseElementVal(arg[x])) || parseElementVal(arg[x])==""){msg(2,arg[x]);return true;};break;
							case "email":if(emailCheck(parseElementVal(arg[x]),arg[y])==false){return true;}break;
							default:break;
						}
					}
				}
			}		
		}
	
		function msg(pval,pObj){
			switch(pval){
				case 1: sabon.msgbox.show("Please enter value.","Validate!",null,null,function get(){pObj.focus();} ); //no value / blank
						break; 
				case 2: //numeric value.
						sabon.msgbox.show("Please enter numeric value.","Validate!",null,null,function get(){pObj.focus();} );
						break; 
				case 3:break;
				default:break;
			}
		}
		
		function parseElementVal(pElement){
				switch(pElement.type){
				case "file" :return pElement.value.strTrim();break;			
				case "text" :return pElement.value.strTrim();break;
				case "select-one": return pElement.value.strTrim();break;
				case "textarea":return pElement.value.strTrim();break;
				default:return "undefined";break;
			}
			
		}
	
	}
	
	//----| gridStripe |---------------------------------------------------------------------------------------------------------------------//
	//format a table with "grid" id.
	function gridStripe(){ //created by gfuentes
		//var tables = sabon.getEName("grid");
		//var isMultiSelect =arguments[0] //boolean for multiple selection 
		var gridId = "GridStyle";
		var tables = sabon.findObjectsByAttr(gridId,"Stripe");
		var markClass="";
		var markOj;
		var marRowId;
			function markOvenOdd(trObj){
				if (trObj){
					if(trObj.rowId%2==0) trObj.className="even"; else trObj.className="odd";
				}
			}
 
			
			for(var x=0;x!=tables.length;x++){
				var table = tables[x];
				var _Selection =table.getAttribute("selection");
				if (!_Selection){_Selection="multiple";}
				_Selection=_Selection.toLowerCase();
			 
				if (!table){return;}
				var trs = table.getElementsByTagName("tr");
				var trsTotal = trs.length;
				for(var i=0; i<trsTotal;i++){
					var startCol= 0;
					if(!trs[i].childNodes[startCol].tagName) {// if th element is defined in (firefox fix)  
						startCol=1;
					}
					if(trs[i].childNodes[startCol].tagName.toLowerCase()!="th"){
						trs[i].rowId=i;
					
						//double click event.
						var prevOnDblClickEvent = trs[i].getAttribute("ondblclick");
						var strFunc ="var tbody = this.parentNode; ";
						strFunc += "var trs =  tbody.getElementsByTagName(\"tr\"); \n";
						strFunc += "	if (trs){\n";
						strFunc += "		for(var i=0;i<trs.length;i++){ \n";
						strFunc += "			var tr= trs[i]; \n";
						strFunc += "			var chkBoxes= trs[i].getElementsByTagName(\"input\"); \n";
						strFunc += "			var chkBox	= chkBoxes[0]; \n";
						strFunc += "			if (chkBox){   \n"; 
						strFunc += "				if(chkBox.type==\"checkbox\"){	\n";
						strFunc += "				var tr = trs[i]; \n";
						strFunc += "					if(chkBox.parentNode.parentNode==this){ \n";
						strFunc += "					 	chkBox.checked=true; \n";
						strFunc += "					 		tr.className=\"selected\";\n";
						strFunc += "					} \n";
							if(_Selection=="single"){
								strFunc += "					else{ \n";
								strFunc += "					 	chkBox.checked=false; \n";
								strFunc += "					 	if(tr.rowId%2==0) tr.className=\"even\"; else tr.className=\"odd\";\n";
								strFunc += "					} \n";
							}
						
						strFunc += "				} \n";
						strFunc += "			} \n";	
						strFunc += "		} \n";
						strFunc += "	this.prevEvent=" + prevOnDblClickEvent + ";if(this.prevEvent){this.prevEvent();} \n";
						strFunc += "} \n";	
						trs[i].ondblclick=Function(strFunc);
									
						var chkBox= trs[i].getElementsByTagName("input")[0];
						//this.c= trs[i].getElementsByTagName("input")[0];
						if (chkBox){
							if(chkBox.type=="checkbox"){
								if (chkBox.checked==true){									 
									trs[i].className ="selected";
								}
								else{
									markOvenOdd(trs[i]) //format tr fill
								}
							 
							 
							 	var prevOnclickEvent = chkBox.getAttribute("onclick");
							 	if(_Selection=="single"){ //single selection during onclick 
									var strFunc ="var tbody = this.parentNode.parentNode.parentNode; \n";
									strFunc += "var trs =  tbody.getElementsByTagName(\"tr\"); \n";
									strFunc += "	if (trs){\n";
									strFunc += "		for(var i=0;i<trs.length;i++){ \n";
									strFunc += "			var tr= trs[i]; \n";
									strFunc += "			var chkBoxes= trs[i].getElementsByTagName(\"input\"); \n";
									strFunc += "			var chkBox	= chkBoxes[0]; \n";
									strFunc += "			if (chkBox){ \n";
									strFunc += "				if(chkBox.type==\"checkbox\"){	var tr = trs[i]; \n";
									strFunc += "					if(chkBox==this){ \n";
									strFunc += "						if(chkBox.checked==true){ \n";
									strFunc += "					 		tr.className=\"selected\";\n";
									strFunc += "					 	} \n";
									strFunc += "					 	else{ \n";
									strFunc += "					 		if(tr.rowId%2==0) tr.className=\"even\"; else tr.className=\"odd\"; \n";
									strFunc += "					 	} \n";
									strFunc += "					} \n";
									strFunc += "					else{ \n";
									strFunc += "					 	chkBox.checked=false; \n";
									strFunc += "					 	if(tr.rowId%2==0) tr.className=\"even\"; else tr.className=\"odd\";\n";
									strFunc += "					} \n";
									strFunc += "				} \n";
									strFunc += "			} \n";	
									strFunc += "		} \n";
									strFunc += "	this.prevEvent=" + prevOnclickEvent + ";if(this.prevEvent){this.prevEvent();} \n";
									strFunc += "} \n";	
								 
									chkBox.onclick=Function(strFunc);
								}
								else{ //multiple selection during onclick 
									var strFunc ="var tr =this.parentNode.parentNode;  ";
									strFunc +="if(tr){"
									strFunc +="if(this.checked){"
									strFunc +=" tr.className =\"selected\";"
									strFunc +="}else{if(tr.rowId%2==0) {tr.className=\"even\";} else {tr.className=\"odd\";}}";
									
									strFunc += "; this.prevEvent=" + prevOnclickEvent + ";if(this.prevEvent){this.prevEvent();}";
									strFunc +="} "
									chkBox.onclick =Function(strFunc);
								}
								
							}
							else{
								markOvenOdd(trs[i]) //format tr fill if not check box	
							}
						
						}
						else{
							markOvenOdd(trs[i]) //if no input elements
						}
						if(sabon.detectBrowser.browser.toLowerCase()=="explorer"){
							if(trsTotal<100){
								trs[i].onmouseover=function(){
									if(marRowId!=this.rowId){
										if(this.className!="selected"){
											if(this.className !="click"){
												this.className ="hover";
												marRowId = this.rowId;
											}
										}
									}
								}
							}
						}
						else{
							trs[i].onmouseover=function(){
								if(marRowId!=this.rowId){
									if(this.className!="selected"){
										if(this.className !="click"){
											this.className ="hover";
											marRowId = this.rowId;
										}
									}
								}
							}
						}
						trs[i].onmouseout=function(){
							if(this.className !="selected"){
								if(this.className !="click"){
									markOvenOdd(this);	
								}
							}
						}
						

						
							
						trs[i].onmousedown=function(){
							var curChkbox = this.getElementsByTagName("input")[0]
							if(markOj){
								var prevBox= markOj.getElementsByTagName("input")[0]
								if (prevBox){
									if(prevBox.type=="checkbox"){
										if (prevBox.checked==false){
											if (curChkbox){
												if (curChkbox.checked!=true){
													markOvenOdd(markOj) //.className = markClass;
													this.className ="click";
													markOj =this;
												}
											}
											else{
													markOvenOdd(markOj) 
													this.className ="click";
													markOj =this;											
											}
										}
										else{
											//if prevBox is checked and if there is a checkbox
											if (curChkbox){
												if (curChkbox.checked!=true){
													if(prevBox){
														if(prevBox.checked!=true){
															markOvenOdd(markOj)  
														}
													}
													this.className ="click";
												} 
											}
											//if not checked 
											markOj =this;
										}
									}
									else{ //if not checkbox element
										 
										markOvenOdd(markOj)
										markOj =this;
										this.className ="click";
										 
									}
								}
								else{
									//if no prev checkbox
									
									if (curChkbox){
										if (curChkbox.checked!=true){
											this.className ="click";
										}
									}
									else{
										this.className ="click";
										}
									if(markOj!=this){
										markOvenOdd(markOj)
										markOj =this;
									}
								}
							}
							else{	
								markOvenOdd(this)
								markOj =this;
								this.className ="click";
							}
						}// end onmousedown
						
					}
				}
				
			}
	}
	
	//----| getQuery  |---------------------------------------------------------------------------------------------------------------------//
	// get a query string or parameters
	function GetQuery(Source,variable) {
	Source = Source.toString().toLowerCase(); 
	variable = variable.toLowerCase();
	var qLoc =  Source.indexOf("?");
	if (qLoc >-1){
			var param = Source.split("?");
		var result = param[1];  //right parameters  
		if (result.indexOf("&") > -1){ 
	 
			var vars = result.split("&");
			for (var i=0;i<vars.length;i++) {
				var pair = vars[i].split("=");
				if (pair[0] == variable) {
	
					return pair[1];
				}
			}
		}
		else{
			var pair = result.split("=");
			if (pair[0] == variable) {
				return pair[1];
			}
	
	
		}
	
	}
	return ""
	}
	
	//----| readCookie  |---------------------------------------------------------------------------------------------------------------------//
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	//----| readCookie  |---------------------------------------------------------------------------------------------------------------------//
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	//----| refresh  |---------------------------------------------------------------------------------------------------------------------//
	function refresh(){
		window.parent.location.reload(true)
	}
	//----| isEmpty  |---------------------------------------------------------------------------------------------------------------------//
	//Added by drchanix
	//Checks if control is empty. Returns an alert message.
	function isEmpty(obj,msg)
	{
		if ((obj.value.length==0) ||
		(obj.value==null))
		{
			alert(msg);
			obj.focus();
			return true;
		}
		else
		{
			return false;
		}
	} 
	
	//----| removeIteminList  |-------------------------------------------------------------------------------------------------------------//
	//Removes an item in Listbox.
	function removeIteminList(objList)
	{
		if (objList.selectedIndex!=-1)
		{
			objList.remove(objList.selectedIndex);
		} 
	}
	
	//----| resetControls  |-------------------------------------------------------------------------------------------------------------//
	//Reset controls to original state.
	function resetControls(obj) {
	var elems = obj.getElementsByTagName('*');
		for (var i=0, j=elems.length; i<j; i++) {
			var e = elems[i];
			myType = e.type;
				
			if(myType){	
				if (myType == 'checkbox' || myType == 'radio')
					e.checked = e.defaultChecked;
				if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea')
				   e.value = e.defaultValue;
				if (myType == 'select-one' || myType == 'select-multiple'){
					var x=false;
					for (var k=0; k<e.length; k++){
						if(e[k].defaultSelected==true)x=true;
						e[k].selected =e[k].defaultSelected;
					}
					if(x==false) e.selectedIndex = 0;
				}
			}
		}
	}
	
	
	//----| DivPopUp  |-------------------------------------------------------------------------------------------------------------//
	//Creates Div element for pop up
	//ex : 
	function DivPopUp(){
		var divPopUpId= "divPopUp";
		this.id = divPopUpId;
		this.unload=removeFunc;
		this.load =loadFunc;
		this.object=getObject;
		function loadFunc(_style){
			_style=_style.toLowerCase();
			var f=":and;"; //format
			var d= sabon.tempElement;
			var _height =  sabon.parseVal(_style,"height",f);
			var _width =  sabon.parseVal(_style,"width",f);
			d.init("div",divPopUpId);
			var move = new sabon.getCenterByHeightWidth(_width,_height);
			d.style("position:absolute;left:" + move.left +  ";top:" + (document.body.scrollTop + move.top)  + ";width:" + _width + ";height:" + _height + ";zindex:" + sabon.makeObjectOnTop());
			d.object.style.backgroundColor="#ffffff";
			d.show();


		}
		function removeFunc(){
			
			var d= sabon.tempElement;
			d.remove(divPopUpId);
		}
		function getObject(){
			return  sabon.getE(divPopUpId);
		}
		
	}
	

	//------------| Format Skin |--------------------------------------------------------------------------------------------//
	//To Format skin of an html element which has innerHTML property like (div, label and td) element.
	//ex:	1) sabon.formatSkin(document.getElementById('divForm'),"skin-a.html","Post Message",_html);
	//		2) sabon.formatSkin(document.getElementById('divForm'),"skin-a.html","Post Message",_html,function myfunc(){alert('alert')}); //return with function
		//ex: formatSkin(document.getElementById('divForm'),"skin-a.html","Post Message",_html);
	//note: (_skinFile) must have these IDs (skin-content_title and skin-content_body)
	function formatSkin(_obj,_SkinFile,_title,_body){
		sabon.getHttpResponse(_SkinFile, callBack,arguments[4])
		function callBack(r){
			var objId= "newObj";
			var tmpE = sabon.tempElement;
			tmpE.init("div",objId)
			tmpE.object.style.display='none';
			tmpE.object.innerHTML=r.text
			sabon.getChildById(sabon.getE(objId),"skin-content_title").innerHTML=_title;
			sabon.getChildById(sabon.getE(objId),"skin-content_body").innerHTML=_body;
			_obj.innerHTML=  getE(objId).innerHTML;
			tmpE.remove(objId);
			sabon.formatGrid(); //refresh grid;
			if(r.args[2]){ //return call back function
				if (typeof(r.args[2])=="function"){
			  		r.args[2]();
					
				}
			}
			

		}
	
	//call local function for refresh formattings.
	//Note: you should your create local function "refreshFormat()"  to refresh your settings or formats. 
		try{refreshFormat();}
		catch(err){}
	
	}
	
	//------------| getChildById |--------------------------------------------------------------------------------------------//
	//to find a child in an element.
	//ex: var child = getChildById("divMain","divChild1");
	function getChildById(parentObj,childID){
		var childs = parentObj.getElementsByTagName('*');
		for (x=0;x<childs.length;x++){
			if(childs[x].id==childID){
				return childs[x];
			}
		}
	}
	
	
	//------------| tempElement |--------------------------------------------------------------------------------------------//
	// to create temporary html element.
	// Ex:  
	//		var elem= sabon.tempElement;
	//		 elem.init("iframe","tmpObj");
	//		 elem.style("left:350;top:200;width:500;height:310;z-index:1000");
	//		 elem.show();
	function TempElement(){
	this.init = _createObj;
	this.remove =remove;
	this.object=Object;
	this.style = setStyle;
	this.show=show;

	function _createObj(htmlTag,tmpID){

		var objCheck  = sabon.getE(tmpID);
		if (!objCheck){ 

			this.object = document.createElement(htmlTag);
			this.object.setAttribute("id", tmpID);
			this.object.frameBorder=0;
			this.object.style.display="none";
			document.body.appendChild(this.object)
		}
		else{this.object = objCheck;}
	//return this.object
	}	
	//show object
	function show(){
	 this.object.style.visibility="visible";
	 this.object.style.display="";
	}

	//-----[ style ]-------------
	 function setStyle(_style){
	 _style=_style.toLowerCase();
	 var f=":and;"; //format
		this.object.style.left= sabon.parseVal(_style,"left",f);
		this.object.style.top= sabon.parseVal(_style,"top",f);
		this.object.style.width= sabon.parseVal(_style,"width",f);
		this.object.style.height= sabon.parseVal(_style,"height",f);
		this.object.style.zIndex= sabon.parseVal(_style,"z-index",f);
		this.object.style.position= sabon.parseVal(_style,"position",f);
		this.object.style.display= sabon.parseVal(_style,"display",f);
	 }	 


	//-----[ remove ]-------------
	function remove(tmpID){
		var obj = sabon.getE(tmpID);
		if(obj){
			document.body.removeChild(obj)
		}
	}
		 
}
	//------------| clearControls |--------------------------------------------------------------------------------------------//
	//Clear controls to blank and selection into none.
	//Ex: sabon.clearControls(document)
	function clearControls(obj)
	{
	var elems = obj.getElementsByTagName('*');
		for (i=0; i< elems.length; i++)
			{
				var doc = elems[i];
				switch (doc.type)
					{
						case "text" : //textbox
							doc.value = "";
							break;
						case "checkbox" : //checkbox
							doc.checked = false;
							break;   
						case "radio" : //radio button
							doc.checked = false;
							break;             											  
						case "select-one" : //select.single
							doc.selectedIndex = 0;
							break;                      
						case "select-multiple" : //select.multiple
							while (doc.selectedIndex != 0)
							{
								  indx = doc.selectedIndex;
								  doc.options[indx].selected = false;
							}
							doc.selected = false;
							break;
							
						default :
							break;
					}
		}
	}
	
	//------------| GetCenterByHeightWidth |--------------------------------------------------------------------------------------------//
	// Example:
	//		var move = new sabon.GetCenterByHeightWidth(objWidth,objHeight);		
	//		sabon.DivPopUp.style("left:" +  move.left + ";top:" + move.top + ";width:" + objWidth + ";height:" + objHeight);
	function GetCenterByHeightWidth(_width,_height){
		
		
		this.left =	(parseInt(screen.width)/2) -  (parseInt(_width) /2);

		this.top =	(parseInt(screen.height)/2) - parseInt(_height);	
		
	 
	
		
		
		
	}
	//------------| MessageBox |--------------------------------------------------------------------------------------------//
	/*
	Example:
	1.)	 sabon.msgbox.show("Message body","Do you want to continue.","yesno","msgquestion",
			 function get(ret){
				alert(ret);
			 }
		 );
	2. )  sabon.msgbox.show("Message body","Do you want to continue.","yesno","msgquestion"); //no callback return.
	3. )  sabon.msgbox.show("Message body","Do you want to continue.","yesno"); //display with default icon with no call back return.  
	4. )  sabon.msgbox.show("Message body","Do you want to continue."); //display with default icon and default button with no call back return.
	5. )  sabon.msgbox.show("Message body"); //display with default (icon,button, and title) with no call back return.
	*/		
	function MessageBox(){ //created by gfuentes
		this.show=msgAlert;
		this.yes=yesFunc;
		this.no=noFunc;
		this.close=closeFunc;
		this._callBackFunc;
		var msgboxId="_MessageBoX1";
		var msgboxPanelID="_MessageBoxPaneL";
		var msgModalCoverId = "msgModalCoveR"
		var response=false;
	   
		function msgAlert(msg){
		if (arguments[1])  var title = arguments[1]; else var title = "Message";	//default title message
		if (arguments[2])  var actionStyle = arguments[2]; else var actionStyle = "okonly"; //default button
		if (arguments[3])  var msgIcon = arguments[3]; else var msgIcon = ""; //default icon
		var callfunction = arguments[4]
		getHttpResponse("controls/messagebox.html", callBack,msg,title,actionStyle,msgIcon)
	
			function callBack(result){
				var _skinHTML = result.text
				var divObj= sabon.tempElement;
				divObj.init("div",msgboxId);
				divObj.style("left:1;top:1;width:350;height:100;position:absolute");
				divObj.object.style.backgroundColor="#ffffff";
				divObj.object.style.visibility="hidden";
				divObj.object.innerHTML=_skinHTML
				
				//insert message title and body
				sabon.getE("msgboxTitleText").innerHTML = result.args[3];
				sabon.getE("msgboxBodyText").innerHTML = result.args[2];
	
				//select action style
				sabon.getE("msgButtonYes").style.display="none";
				sabon.getE("msgButtonNo").style.display="none";
				sabon.getE("msgButtonOk").style.display="none";
				sabon.getE("msgButtonCancel").style.display="none";
	
				switch(actionStyle.toLowerCase()){
					case "yesno":
						sabon.getE("msgButtonYes").style.display="";
						sabon.getE("msgButtonNo").style.display="";	
						sabon.getE("msgboxCloseButton").disabled=true;
						
						break;
					case "okonly":
						sabon.getE("msgButtonOk").style.display="";		
						break;
					case "okcancel":
						sabon.getE("msgButtonOk").style.display="";
						sabon.getE("msgButtonCancel").style.display="";				
						break;
					default: alert("[" + actionStyle + "]\nParameter not registered.\nPls. choose one [\"yesno\",\"okonly\", or \"okcancel\"].");break;
						
				}
				//initialize div object to display
				var _width = getE(msgboxId).offsetWidth;
				var _height = getE(msgboxId).offsetHeight;
				var move = new sabon.getCenterByHeightWidth(_width,200);	
				var _objectZindex = sabon.makeObjectOnTop()
				
				divObj.style("left:" + move.left + ";top:" + move.top + ";z-index:" + (_objectZindex+2) +";position:absolute");
				divObj.show();	
				
				//Message icon
				var msgIconStr = result.args[5].toLowerCase();
				var msgIconObj = sabon.getE("msgboxLogoIcon");
				
				switch(msgIconStr){
					case "msginfo": msgIconObj.style.background = "url(images/messagebox/info.gif)";break;
					case "msgquestion": msgIconObj.style.background = "url(images/messagebox/question.gif)";break;				
					case "msgcritical": msgIconObj.style.background = "url(images/messagebox/critical.gif)";break;				
					default: msgIconObj.style.background = "url(images/messagebox/default.gif)";break;						
				}
				
				
				var _offsetWidth=sabon.getE(msgboxId).offsetWidth;
				var _offsetHeight=sabon.getE(msgboxId).offsetHeight;	
				var _offsetTop=sabon.getE(msgboxId).offsetTop;	
				var _offsetLeft=sabon.getE(msgboxId).offsetLeft;	
				var _scrollTop =  document.body.scrollTop
				//move div object to center
				divObj.style("left:" + _offsetLeft + ";top:" + (_scrollTop + _offsetTop) + ";z-index:" + (_objectZindex+2) +";position:absolute");
				
				//createIframe element to cover the dropdownlist and flash media.
				var iframeObj= sabon.tempElement;
				iframeObj.init("iframe",msgboxPanelID);
				
				iframeObj.style("left:" + _offsetLeft + ";top:" + (_scrollTop + _offsetTop) + ";width:" + _offsetWidth + ";height:" + _offsetHeight + ";position:absolute;z-index:" + (_objectZindex+1));
				iframeObj.object.style.backgroundColor="#ffffff";
				iframeObj.show();
	
				//cover whole window
				var wh = new sabon.getWindowHeightWidth;
				var divCoverObj= sabon.tempElement;
				divCoverObj.init("div",msgModalCoverId);
				divCoverObj.style("left:0;top:0;width:" + wh.width + ";height:" + wh.height + ";position:absolute:z-index:" + _objectZindex);
				divCoverObj.object.style.backgroundColor="#000000";
				divCoverObj.show();
				
				if(divCoverObj.object.filters){   //detect filters object in browser
					divCoverObj.object.style.filter= "alpha(opacity=35)";
				}
				else{
					divCoverObj.object.style.MozOpacity=35/100;
				}
			}// end of callBack function	
			this._callBackFunc=callfunction;
		}//end of msgAlert
			 
		function yesFunc(){
			response=true;
			if(typeof(this._callBackFunc)=="function" ){
				this._callBackFunc(response);
			}
			closeFunc();
		}
		function noFunc(){
			response=false;
			if(typeof(this._callBackFunc)=="function" ){
				this._callBackFunc(response);
			}
			closeFunc();
		}
		function closeFunc(){
			sabon.tempElement.remove(msgModalCoverId);	
			sabon.tempElement.remove(msgboxPanelID);
			sabon.tempElement.remove(msgboxId);
			
		}
	}
	
	
	//------------| makeObjectOnTop |--------------------------------------------------------------------------------------------//
	function MakeObjectOnTop(){
	
	var zIndex=0;
	var _tmpIndex=0;
	var elems = document.getElementsByTagName('*');
		for(i=0;i<elems.length;i++){
			_tmpIndex=elems[i].style.zIndex 
			if(_tmpIndex>0){
				if(zIndex<_tmpIndex){
					zIndex=_tmpIndex;
				}
			}
		}
	return zIndex+1 
	}
	
	//------------| GetWindowHeightWidth |--------------------------------------------------------------------------------------------//
	//to get height and width of window browser
	function GetWindowHeightWidth(){
	this.height=0;
	this.width=0;
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		//myWidth = window.innerWidth-1;
		myWidth  = document.body.scrollWidth - 1;
		
		//myHeight = window.innerHeight-1;
		myHeight = document.body.scrollHeight - 1;
		
	  } 
	  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		//myWidth = document.body.clientWidth  - 1;
		myWidth  = document.body.scrollWidth - 1;
		
		//myHeight = document.body.clientHeight - 1;
		myHeight = document.body.scrollHeight - 1;

		
	}
		this.width = myWidth ;
		this.height = myHeight;
	}
	
	function RequestStatusBox(){
	var waitRequestID ="waitRequestIdDiV";
	this.start = RequestStart;
	this.stop = RequestStop;
	this.close = CloseFunc;
		function RequestStart(){
			var _html  = "<div style=\"padding:15px;\"><img src=\"images/loading.gif\" /> Loading... <input type=\"button\" value=\"Abort\" onclick=\"(new sabon.requestStatusBox).close();\" /></div>"
			var waitObj= sabon.tempElement;
			waitObj.init("div",waitRequestID);
			waitObj.style("left:100;top:100;position:absolute");
			waitObj.object.style.backgroundColor="#ffffff";
			waitObj.object.style.border="1pt solid #DECCCC";
			
			waitObj.object.innerHTML = _html;
			
			var move = new sabon.getCenterByHeightWidth(waitObj.object.offsetWidth, 150);
			waitObj.object.style.left =move.left;
			waitObj.object.style.top =0;
			waitObj.object.style.zIndex = sabon.makeObjectOnTop()
						
			if(waitObj.object.filters){   //detect filters object in browser
				waitObj.object.style.filter= "alpha(opacity=90)";
			}
			else{
				waitObj.object.style.MozOpacity=90/100;
			}
			waitObj.show();
		}	
		function RequestStop(){
			sabon.xmlHttpObject.abort();
		}
		function CloseFunc(){
			sabon.tempElement.remove(waitRequestID);
		}
	}
	

	//------------| IsNumeric |--------------------------------------------------------------------------------------------//
		//Checks for numeric entry.
	function IsNumeric(strString){
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
		for (i = 0; i < strString.length && blnResult == true; i++){
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1){
				blnResult = false;
			}
		}
		return blnResult;
	}

	//------------| debug |--------------------------------------------------------------------------------------------//
	function debug(){
		var msg = arguments[0]
		var isLeftPos = arguments[1]
		if(!isLeftPos) isLeftPos=false;
	
		
		var divDebugId="divDebug"; 
		var elem= sabon.tempElement;
		 elem.init("div",divDebugId);
		 var hw =new sabon.getWindowHeightWidth;
		 var _top = 0;
		 var _width=300;
		 var _height =100;
		 if (!isLeftPos==true) var _left = (hw.width-_width);	 else var _left =0
		 elem.style("position:absolute;left:" + _left + ";top:" + _top + ";width:" + _width + ";height:" + _height +";z-index:" + sabon.makeObjectOnTop());
		 elem.object.style.backgroundColor="#ffffff";
		 elem.object.style.border="1pt solid #000";
		 elem.object.style.padding="5px";
		 elem.object.nowrap=false;
		 elem.object.innerHTML=msg;
		 elem.object.title ="double click to close this form";
		 elem.show();
		 elem.object.ondblclick = function(){
			var elem= sabon.tempElement;
			elem.remove(divDebugId);
		 }
	}

	//------------| inherits from (copyPrototype)|--------------------------------------------------------------------------------------------//
	//Pls. refer to : http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/
	function inherits(descendant, parent) { 
	    var sConstructor = parent.toString(); 
	    var aMatch = sConstructor.match( /\s*function (.*)\(/ ); 
	    if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; } 
	    for (var m in parent.prototype) { 
	        descendant.prototype[m] = parent.prototype[m]; 
	    } 
	}
	
	//------------| getChildsById|--------------------------------------------------------------------------------------------//
	function getChildsById(parentObj,childID){
		var arrObj = new Array();
		var childs = parentObj.getElementsByTagName('*');
		for (x=0;x<childs.length;x++){
			if(childs[x].id==childID){

				arrObj.push(childs[x]);
			}
		}
		return arrObj;
	}
	

	//------------| BrowserDetect|--------------------------------------------------------------------------------------------//
	// origin: http://www.quirksmode.org/js/detect.html
	//ex: 
	//	var dbr =sabon.detectBrowser;
	//	alert("browser :" + dbr.browser + " , Version :" + dbr.version +  " , OS :" + dbr.OS)
function DetectBrowser(){
	var dataBrowser =[
		 { 	string: navigator.userAgent,subString: "OmniWeb",versionSearch: "OmniWeb/",identity: "OmniWeb"}
		,{  string: navigator.vendor,subString: "Apple",identity: "Safari"}
		,{  prop: window.opera,identity: "Opera"}
		,{  string: navigator.vendor,subString: "iCab",identity: "iCab"}
		,{  string: navigator.vendor,subString: "KDE",identity: "Konqueror"}
		,{  string: navigator.userAgent,subString: "Firefox",identity: "Firefox"}
		,{  string: navigator.vendor,subString: "Camino",identity: "Camino"}
		,{	string: navigator.userAgent,subString: "Netscape",identity: "Netscape"}
		,{  string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}
		,{  string: navigator.userAgent,subString: "Gecko",identity: "Mozilla",versionSearch: "rv"}
		,{ 	string: navigator.userAgent,subString: "Mozilla",identity: "Netscape",versionSearch: "Mozilla"}
	]
	var dataOS =[
		 {	string: navigator.platform,subString: "Win",identity: "Windows"}
		,{	string: navigator.platform,subString: "Mac",identity: "Mac"}
		,{	string: navigator.platform,subString: "Linux",identity: "Linux"}
	]
	this.searchString = SearchString;
	this.searchVersion = SearchVersion;
	function SearchString(data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	}
	function SearchVersion(dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	}

	//Initialize
	this.browser = this.searchString(dataBrowser) || "An unknown browser";
	this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
	this.OS = this.searchString(dataOS) || "an unknown OS";
	}
	//------------| FormatDate|--------------------------------------------------------------------------------------------//
	// origin: petc_iqms/js [EdEntry.asp]
	//ex:  sabon.formatDate("January 10, 2008")
	function FormatDate(p_date){
		var l_Date = new Date(p_date);
		return l_Date;
	}
	//------------| IsValidDate|--------------------------------------------------------------------------------------------//
	// origin: petc_iqms/js [EdEntry.asp]
	//ex:  sabon.isValidDate("10000/2008")
	function IsValidDate(dateStr){
	  var datePat = /^(\d{1,2})\/(\d{1,2})\/(\d{4})?$/;
	  var matchArray = dateStr.match(datePat);
	  if(!matchArray)  matchArray = dateStr.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2})?$/);
	  if (matchArray == null) {return false;}
	  mnth = matchArray[1];
	  dy = matchArray[2];
	  yr = matchArray[3];
		  
	  if ((mnth < 0 || mnth > 12) || (dy < 0 || dy > 31)){
		  return false;
	  }  
		  
	  if (mnth == 2){
		leapyr = yr % 4
		if (leapyr == 0){
		  maxday = 29
		}
		else{
		  maxday = 28
		}  
		if (dy > maxday){
		  return false;
		}  
	  }
	  if ((mnth == 1) || (mnth == 3) || (mnth == 5) || (mnth == 7) || (mnth == 8) || (mnth == 10) || (mnth == 12)){
		maxday = 31
		if (dy > maxday){
		  return false;
		}
	  }
	  if ((mnth == 4) || (mnth == 6) || (mnth == 9) || (mnth == 11)){
		maxday = 30
		if (dy > maxday){
		  return false;
		}
	  }
	  return true;
	}
	//------------| RefreshContent|--------------------------------------------------------------------------------------------//
	/*Ex.
		sabon.refreshContent("adminManageUsers.asp","gridPanel",callBack);
		function callBack(r){
			sabon.formatGrid();
		}
	*/
	function RefreshContent(pageName,contentId,passCallBack){
		var divId= "_RefrEshConTenT"
		var gridPanelId="";
		var i=0;
		var args;
		
		sabon.getHttpResponse(pageName,callBack,passCallBack,contentId); 
		if(sabon.detectBrowser.browser.toLowerCase()=="firefox"){ //double refresh if firefox // element refresh problem
			sabon.getHttpResponse(pageName,callBack,passCallBack,contentId);
		}
		function callBack(r){
				args = r.args;
			 	gridPanelId =r.args[3] //content id
			var te = sabon.tempElement;
				 te.init("div",divId);
				 te.object.innerHTML =r.text
				//tmpObj.innerHTML =r.text
				var gridUpdatedPanel = sabon.getChildById(te.object,gridPanelId);
				var  innerUpdate = gridUpdatedPanel.innerHTML;
				var gridOriginPanel = sabon.getE(gridPanelId);
			 	gridOriginPanel.innerHTML=innerUpdate;
				te.remove(divId);
				if(args[2]){args[2]();}; // calling CallBack which is passCallBack

		}	
	}
	//------------| getCheckValues|--------------------------------------------------------------------------------------------//
	// To get checked items in a table elements
	//ex: var result = sabon.getCheckObjectsToArray("grid","chkID","lastName")
	function GetCheckObjectsToArray(table,chkBoxId,FieldId){
		
		var items = new Array;
		
		if(typeof(table)=="object"){
			var chks = sabon.getChildsById(table,chkBoxId);
		}
		else{
			var chks = sabon.getChildsById(sabon.getE(table),chkBoxId);
		}		
		for(i=0;i<chks.length;i++){
			if(chks[i].checked==true){
				var tr = chks[i].parentNode.parentNode //tr
				  items.push(sabon.getChildById(tr,FieldId));
			}
		}
		return items;
	}
	

	
	
	
	
	//------------| ArrToDelimitedString |--------------------------------------------------------------------------------------------//
	// To convert array to a delimeted string.
	//ex: 1)  var str = sabon.arrToDelimitedString(objs); //default delimiter is ","
	//    2)  var str = sabon.arrToDelimitedString(objs,":"); //with customized delimiter ":"
	function ArrToDelimitedString(objects){
		if(!arguments[1]) delimiter=","; else delimiter=arguments[1];
		var str="";
		if(objects[0]){ //check if it is defined object
			if (objects[0].tagName){ //DOM elements
				switch(objects[0].tagName.toLowerCase()){
					case "input" :
							for(var i=0; i<objects.length;i++){
								switch(objects[i].type.toLowerCase()){
									case "checkbox": str += objects[i].checked + delimiter;	break;
									default:str += objects[i].value + delimiter;	break;
								}
							}
						break;
					case "select" : for(var i=0; i<objects.length;i++) str += objects[i].value + delimiter; break;
					default: for(var i=0; i<objects.length;i++) str += objects[i].innerHTML + delimiter; break;	
				}
			}
			else{for(var i=0; i<objects.length;i++) str += objects[i] + delimiter;} ////not DOM elements
		}
		return str.substr(0,(str.length)-(delimiter.length))	
	}

	//------------| getChilds|--------------------------------------------------------------------------------------------//
	// To get elements in a parent object
	//ex: sabon.getChilds(document);
	function getChilds(parentObj){
		return parentObj.getElementsByTagName('*');
	}
	//------------| Collection|--------------------------------------------------------------------------------------------//
	// Used for Objects Collection 
	// Ex:  var c = sabon.collection;
	//	  c.add("SId",s.id.value);
	//	  c.add("FName",s.fname.value);
	//	  c.add("LName",s.lname.value);
	function Collection(){
		this.add =AddFunc;
		this.remove = RemoveFunc;
		this.items = new Array;
		
		function AddFunc(_id,_value){
			var i = new ItemInfo;
			i.id=_id;
			i.value=_value;
			this.items.push(i);
		}
		function ItemInfo(){
			this.id;
			this.value;
		}
		function RemoveFunc(i){
			this.items.splice(i,1);
		}
	}

	//------------| SetObjectValue|--------------------------------------------------------------------------------------------//
	// To set value of an object element. 
	//Ex sabon.setObjectValue(divObj,"hello world")
	function SetObjectValue(_Obj,_value){
		if (_Obj.tagName){ //DOM elements
			switch(_Obj.tagName.toLowerCase()){
				case "input" :
							switch(_Obj.type.toLowerCase()){
								case "checkbox": _Obj.checked =sabon.cBit(_value); break;
								default:_Obj.value=_value; break;
							}
					break;
				case "select":_Obj.value =_value ;break;  
				default:
					//if(_value=="") _value ="&nbsp;"; 
					_Obj.innerHTML=_value; break;
			}
		}
	}
	//------------| GetObjectValue|--------------------------------------------------------------------------------------------//
	// To get value of an object element. 
	//Ex alert(sabon.getObjectValue(divObj))
	function GetObjectValue(_Obj){
			//	alert(_Obj);
		//return false;
		if(_Obj){
		if (_Obj.tagName){ 

			switch(_Obj.tagName.toLowerCase()){
				case "input" :
							switch(_Obj.type.toLowerCase()){
								case "checkbox": return _Obj.checked; break;
								default: return _Obj.value; break;  
							}
					break;
				case "select": retValue = _Obj.value; break;  
				default: return _Obj.innerHTML; break;
					
			}
		}
		}
	}

	//------------| TableHTML|--------------------------------------------------------------------------------------------//
	// class HTML table
	function TableHTML(){
		this.addRow					= AddRowTable;
		this.updateRow				= UpdateRowTable;
		this.deleteRowByCheckedBox	= DeleteRowByCheckedBox;
		this.searchAll				= SearchAllFunc;
		this.searchByColumnIndex 	= SearchByColumnIndexFunc;
		this.filter					= FilterFunc;
		//------------| AddToTable|--------------------------------------------------------------------------------------------//
		// Used to add Collections to table element
		//Ex.  var c = sabon.collection;
		//  	c.add("EmpId","12808");
		// 	 	c.add("FName","Gerry");
		//  	c.add("LName","Fuentes");
		//  	sabon.tableHTML.addRow("grid",c);	
		function AddRowTable(_tableId,_itemsCollection){
		var table = sabon.getE(_tableId);
		var tbody = table.getElementsByTagName("tbody")[0];
		var trs =  tbody.getElementsByTagName("tr");
			if(trs[trs.length-1]) var tr  =  trs[trs.length-1].cloneNode(true);
			tbody.appendChild(tr);
			for(i=0;i<_itemsCollection.items.length;i++){
				var _obj =sabon.getChildById(tr,_itemsCollection.items[i].id);
				if(_obj) sabon.setObjectValue(_obj, _itemsCollection.items[i].value);
			}
			tr.style.display="";
		}

		//------------| UpdateRowTable|--------------------------------------------------------------------------------------------//
		// To update records on a table elements
		//Ex.:  var c = new sabon.collection;
		//  	c.add("SId","12808);
		//  	c.add("FName","German");
		//  	c.add("LName","Fuentes");
		// 		 sabon.tableHTML.updateRow("grid",c);
		function UpdateRowTable(_tableId,_itemsCollection){
		var iCol = _itemsCollection;
		var primary = iCol.items[0] 
		var table = sabon.getE(_tableId);
		var tbody = table.getElementsByTagName("tbody")[0];
		var trs =  tbody.getElementsByTagName("tr");
		
			for(var x=0;x<trs.length;x++){
				var tr = trs[x];
				var obj = sabon.getChildById(trs[x],primary.id)
				if(sabon.getObjectValue(obj)==primary.value){
					  for(i=1;i<iCol.items.length;i++){
						var _obj =sabon.getChildById(tr,iCol.items[i].id);
						if(_obj) sabon.setObjectValue(_obj, iCol.items[i].value);
					}
				}
			}
		}
		//------------| DeleteRowTable|--------------------------------------------------------------------------------------------//
		// To delete record with checked value 
		// Ex.: sabon.tableHTML.deleteRowByCheckedBox("grid");
		// Ex.: sabon.tableHTML.deleteRowByCheckedBox(gridObject);
		function DeleteRowByCheckedBox(tbl){
			_proccess: while(true) {
				if(typeof(tbl)=="object"){
					var table = tbl;										
				}else{
					var table = sabon.getE(tbl);					
				}
				var inputs = table.getElementsByTagName("input");
				
				if(inputs){
					for(var i=0;i<inputs.length;i++){
						var input = inputs[i];
						if(input.type.toLowerCase()=="checkbox"){
							if(input.checked==true){
								var tr = input.parentNode.parentNode;
								var tbody = input.parentNode.parentNode.parentNode;
								tbody.removeChild(tr);
								continue _proccess;
								//break _proccess; //break to end loop
							}						
						}
					}
				}
				break _proccess;
			}
		}
		//------------| searchAll - to search values in all columns|--------------------------------------------------------------------------------------------//	
		//example: sabon.tableHTML.searchAll(this,new bestPractice.gridListObject)
		function SearchAllFunc(phrase, htmlObject){
			var words = phrase.value.toLowerCase().split(" ");
			var table = htmlObject
			var ele;
			var s="";
			if(table.rows){
				for (var r = 1; r < table.rows.length; r++){
					var ths =table.rows[r].getElementsByTagName("th");
					if(ths.length==0){		
						ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
						var displayStyle = 'none';
						for (var i = 0; i < words.length; i++) {
							if (ele.toLowerCase().indexOf(words[i])>=0)
								displayStyle = '';
							else {
								displayStyle = 'none';
								break;
							}
						}
					table.rows[r].style.display = displayStyle;
					}
				}
			}else{alert("Table parameter is not an object.");}
		}
		//------------| searchByColumnIndex -  to search values in an index column|--------------------------------------------------------------------------------------------//
		//example : sabon.tableHTML.searchByColumnIndex(this,new bestPractice.gridListObject,1)
		function SearchByColumnIndexFunc(term, htmlObject, cellNr){
			var keyword = term.value.toLowerCase();
			//var table = document.getElementById(_id);
			var table = htmlObject;
			var ele;
			if(table.rows){
				for (var r = 1; r < table.rows.length; r++){
					var ths =table.rows[r].getElementsByTagName("th");
					if(ths.length==0){	
						ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g,"");
						if (ele.toLowerCase().indexOf(keyword)>=0 )
							table.rows[r].style.display = '';
						else table.rows[r].style.display = 'none';
					}
				}
			}else{alert("Table parameter is not an object.");}
		}
		//------------| filter -  to filter records by columns and value|--------------------------------------------------------------------------------------------//
		//example: filter(new bestPractice.gridListObject,'2=rest,title;3=menu,list')
		function FilterFunc(htmlObject,keywords){
			if(keywords.substr(0,1)==";") keywords = keywords.substr(1, keywords.length-1);
			if(keywords.substr(keywords.length-1,1)==";") keywords = keywords.substr(0, keywords.length-1);
			var arrSearchCols = keywords.split(";");
			var table = htmlObject;
			var ele;
			if(table.rows){
				for (var r = 1; r < table.rows.length; r++){
					var ths =table.rows[r].getElementsByTagName("th");
					if(ths.length==0){	
						
						if (findValueInRow(table.rows[r],keywords))
								table.rows[r].style.display = '';
						else table.rows[r].style.display = 'none';
						
					}
				}
			}else{alert("Table parameter is not an object.");}

			function findValueInRow(rowObj,keywords){
				var arrSearchCols = keywords.toLowerCase().split(";");
				for(var x=0;x<arrSearchCols.length;x++){
						var colIndex = arrSearchCols[x].split("=")[0] 
						var searchKeys =arrSearchCols[x].split("=")[1].split(",")  //array
						var strHtml = rowObj.cells[colIndex].innerHTML.replace(/<[^>]+>/g,"").toLowerCase();
						for(var i=0;i<searchKeys.length;i++){
							 var result=sabon.searchStr.isFound(strHtml,searchKeys[i])
							// alert(strHtml + "::" +searchKeys[i])
							 if(result) {return true;}
						}
				}
				return false;		
			}
		}


	}// end of TableHTML class.

	//------------| GetEByAttributeName|--------------------------------------------------------------------------------------------//
	// is used to get elements by attribute name.
	// Ex.: var objects = sabon.getEByAttrName(document,"grid");
	function GetEByAttributeName(parent,attributeName){
		var items = new Array();
		var objects = parent.getElementsByTagName("*");
		for(i=0;i<objects.length;i++){
			 var  obj = objects[i]
			 var  attr = obj.getAttribute(attributeName)
			 if(attr){
				items.push(obj)
			}
		}
		return items;
	}
	//------------| GetObjectsByAttr|--------------------------------------------------------------------------------------------//
	// is used to get elements by attribute name and value.
	// Ex.:	1) var objects = sabon.findObjectsByAttr("GridStyle","grid");
	// 		2) var objects = sabon.findObjectsByAttr("ClassName","PopUpCSS");
	
	function FindObjectsByAttr(property,value){
		var items = new Array;
		var objects = sabon.getEByAttrName(document,property);
		
			for(var i=0;i<objects.length;i++){
				var object = objects[i]
				var propertyValue = object.getAttribute(property).toLowerCase();
				if (propertyValue == value.toLowerCase()){
					 items.push(object);
				}
			}
		
		return items;
	}
	
	//------------| GetObjectsByAttr|--------------------------------------------------------------------------------------------//
	// Creates document class which consist of elements based on the parent object/id.
	// Ex. 1) var d =  sabon.CreateDocClass("DataEntry");
	// Ex. 2) var d =  sabon.CreateDocClass("DataEntry",document);
	


	function CreateDocClass(parentId){
	var strClassName =  "this." + parentId; 
	var strFunc="";
		strFunc += strClassName + "=function(){\n";
		var parentPanel = arguments[1]
		if(parentPanel){
			var  parent = sabon.getChildById(parentPanel,parentId);
			
			if(parentPanel.id){
				strFunc +="var parent = sabon.getChildById(sabon.getE(\"" + parentPanel.id + "\"),\"" + parentId + "\");\n";
			}
			else{
				strFunc +="var parent = sabon.getChildById(document,\"" + parentId + "\");\n";
			}
		}
		else{
			var  parent = sabon.getChildById(document,parentId);
			strFunc +="var parent = sabon.getChildById(document,\"" + parentId + "\");\n";
		}
		
		var childs = parent.getElementsByTagName("*");
		for(var i=0;i<childs.length;i++){
			if(childs[i].id){
				var exists = strFunc.indexOf("this." + childs[i].id + "=");
				if (exists < 0){
					var countE =sabon.getChildsById(parent,childs[i].id).length;
					if(countE>1)
						strFunc +="this." + childs[i].id + "=sabon.getChildsById(parent,\"" + childs[i].id  + "\");\n"; //if having duplicates
					else
						strFunc +="this." + childs[i].id + "=sabon.getChildById(parent,\"" + childs[i].id  + "\");\n";			
				}
			}
		}
		strFunc +="}";

		Function(strFunc)();
		return Function("return new " + strClassName)();
	}


	//check only one of all checkboxes elements 
	
	function CheckOneByObject(obj){
		var tbody = obj.parentNode.parentNode.parentNode;
		var trs =  tbody.getElementsByTagName("tr");
		if (trs){
			for(var i=0;i<trs.length;i++){
			var chkBox= trs[i].getElementsByTagName("input")[0];
				if (chkBox){
					if(chkBox.type=="checkbox"){
						if(chkBox!=obj){
							chkBox.checked=false;
							var tr = trs[i];
							if(tr.rowId%2==0) tr.className="even"; else tr.className="odd";
							
						}
					}
				}
			}
		}
	}
	

	//this function could not be used for scripting
	function logURL(url){
		sabon.listURL.push(url);
		var lenArr = sabon.listURL.length; 
		if(lenArr>20){sabon.listURL.splice(0,1);} //you can limit history here.
	}
	
	

	//------------| GetURLParamsVal|--------------------------------------------------------------------------------------------//
	// get value from history urls by parameter/querystrings .
	// Ex. 1) var result =  sabon.getURLParamsVal("param1");
	function GetURLParamsVal(searchItem){
		var lenArr = sabon.listURL.length
		for (var i=lenArr-1;i>-1;i--){
			var r = sabon.getQuery(sabon.listURL[i],searchItem);
			if (r) return r;
		}
		//if single form only.
		var r = sabon.getQuery(window.location.href,searchItem);
		if (r) return r;
	}

	//------------| FileString Class|--------------------------------------------------------------------------------------------//
	// get a string value from a file name by extension, filename only, path/directory and format directory.
	//Example:
	//var fi = sabon.fileString;
	//1) var r = fi.fileName(sFile);
	//2) var r = fi.extension(sFile);
	//3) var r = fi.path(sFile);
	//4) var r = fi.formatPath(sFile);
	
	function FileString(){
		this.extension 		= ExtensionFunc;
		this.fileName 		= FileNameFunc;
		this.filePath 		= pathFunc;
		this.formatPath		= FormatPathFunc;
		var bSlash = "\\"; //back slash
		var fSlash ="/";   //front slash
	
		function pathFunc(sFile){
				var sFullPath = this.formatPath(sFile);
				var aFile = sFullPath.split(bSlash);
				var sResultFileName = aFile[aFile.length-1];
				return sFullPath.replace(sResultFileName,"");
		}
		
		function FormatPathFunc(aFile){
			var aFile = aFile.split(bSlash);
			if(aFile.length){
				var sPath = aFile[0];
				for (var x=1;x<aFile.length;x++){
					if(aFile[x].strTrim()){
						sPath += bSlash + aFile[x];
					}
				}
				return sPath
			}
			
			
		}
		
		function ExtensionFunc(sFile){
			
			var sFullPath = this.formatPath(sFile);
			var aFile = sFullPath.split(bSlash);
			var sResultFileName = aFile[aFile.length-1];
			var aResultFileName = sResultFileName.split(".");
			return  aResultFileName[aResultFileName.length-1];
	
		}
		function FileNameFunc(sFile){
			var sFullPath = this.formatPath(sFile);
			var aFile = splitSlash(sFile);
			return aFile[aFile.length-1];
		}
		function splitSlash(sFile){
			if(sFile.indexOf(fSlash)>-1){
				return sFile.split(fSlash);
			}
			else{
				return sFile.split(bSlash);
			}
				
		}
	}

	//------------| IsAllowedFile |--------------------------------------------------------------------------------------------//
	// To check the file by extension name to be allowed.
	//Example:
	//	var r = sabon.isAllowedFile("d:\\fuentes\\file.png","gif,jpg,png")
	function IsAllowedFile(sFile,sAllowedExtensions){
		sFile = sFile.toLowerCase();
		var ext = sabon.fileString.extension(sFile);
		var aAllowed = sAllowedExtensions.split(","); 
			for(var x=0;x<aAllowed.length;x++){
				if(ext==aAllowed[x]) return true;
			}
			
		return false;	
	}

	//------------| SearchStr |--------------------------------------------------------------------------------------------//
	// To search for a string 
	//Example:
	//	var r = sabon.searchStr.itemsIndex("abcdab","a")
	//	var r = sabon.searchStr.isFound("abcd","a")

	function SearchStr(){
		this.isFound=IsFoundFunc;
		this.itemsIndex=ItemsIndexFoundFunc;
		function IsFoundFunc(source,keyword){
			var pos = source.indexOf(keyword);
			if (pos>-1) 
				return true;
			else
				return false;
		}
		function ItemsIndexFoundFunc(source,keyword){
			var items = new Array;
			for(var x=0;x<source.length;x++){
				var pos = source.substr(x).indexOf(keyword);
					if (pos>-1){ 
						items.push(x + pos);
						x= x + pos + (keyword.length-1);
					}
			}
			return items;
		}
	}



	//------------| Listbox Class |--------------------------------------------------------------------------------------------//
	// getIndexValueOfListBox  - use to find value of dropdown box elements and return the index of an item found.
	//Example:
	//var lb = sabon.listBox;
	//var cmbTool = document.getElementById("cmbTool");
	//var index =lb.find(cmbTool,"Quality",lb.searchType.byText);
	//alert(index);

	function ListBox(){
		this.find=findFunc;
		this.searchType = {byValue:0,byText:1};
		function findFunc(oList,keyword){
			var sType;
			if(!arguments[2]) sType=this.searchType.byValue; else sType=this.searchType.byText;
	
			if(oList){
				for(var x=0;x<oList.length;x++){
						if(sType==this.searchType.byValue){
							if(oList.options[x].value==keyword) return x;
						}
						else{
							if(oList.options[x].text==keyword) return x;
						}
				}
			}
		}
	}
 

	//------------| CheckAllBoxes function |--------------------------------------------------------------------------------------------//
	// getIndexValueOfListBox  - use to (check/uncheck) all boxes once the header box is checked/unchecked, this will work on onmousedown event.
	//Example:
	// 1. <input type="checkbox" Id="chkSelect" onmousedown="sabon.checkAllBoxes(this);"  />
	// 2. <asp:CheckBox ID="chkSelect" runat="server"  onmousedown="sabon.checkAllBoxes(this);"  />

 	function CheckAllBoxes(obj){
		var mainbox = obj.getElementsByTagName("input")[0];
	//	alert(mainbox.checked)
        var tbody=obj.parentNode.parentNode.parentNode;
        var trs =tbody.getElementsByTagName("tr");
		 
            for(var x=0; x<trs.length;x++){
				
				if(sabon.detectBrowser.browser.toLowerCase()=="explorer") 
					var child=trs[x].childNodes[0];  
				else 
					var child=trs[x].childNodes[1];  
				if(child.tagName.toLowerCase()=="td"){
					 
                   var inputs = trs[x].getElementsByTagName("input");
                   if(inputs){
                       var input = inputs[0];
					   
                       if (input){
						   //alert(input.type)
                            if(input.type.toLowerCase()=="checkbox"){
								
                               if(mainbox.checked==false) 
                                    input.checked=true;
                               else
                                    input.checked=false;
                            }
                       }
                   }
                }
            }        
	}

//-----END OF METHODS ----Note: pls. insert above this line your additional method for SABON Class---------------//
}



